VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomct2.ocx"
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "mshflxgd.ocx"
Object = "{0D452EE1-E08F-101A-852E-02608C4D0BB4}#2.0#0"; "FM20.DLL"
Begin VB.Form FTipoCambio 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Tipo de Cambio"
   ClientHeight    =   4935
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   7575
   Icon            =   "FTipoCambio.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4935
   ScaleWidth      =   7575
   StartUpPosition =   1  'CenterOwner
   Begin VB.Frame FraBotones 
      Height          =   4335
      Left            =   120
      TabIndex        =   9
      Top             =   480
      Width           =   1575
      Begin MSForms.CommandButton CmdGuardar 
         Height          =   375
         Left            =   120
         TabIndex        =   13
         Top             =   2160
         Visible         =   0   'False
         Width           =   1335
         Caption         =   " Guardar"
         PicturePosition =   327683
         Size            =   "2355;661"
         Picture         =   "FTipoCambio.frx":058A
         FontHeight      =   165
         FontCharSet     =   0
         FontPitchAndFamily=   2
         ParagraphAlign  =   3
      End
      Begin MSForms.CommandButton CmdCancelar 
         Height          =   375
         Left            =   120
         TabIndex        =   14
         Top             =   2640
         Visible         =   0   'False
         Width           =   1335
         Caption         =   " Cancelar"
         PicturePosition =   327683
         Size            =   "2355;661"
         Picture         =   "FTipoCambio.frx":06E4
         FontHeight      =   165
         FontCharSet     =   0
         FontPitchAndFamily=   2
         ParagraphAlign  =   3
      End
      Begin MSForms.CommandButton CmdEliminar 
         Height          =   375
         Left            =   120
         TabIndex        =   12
         Top             =   1200
         Width           =   1335
         Caption         =   " Eliminar"
         PicturePosition =   327683
         Size            =   "2355;661"
         Picture         =   "FTipoCambio.frx":083E
         FontHeight      =   165
         FontCharSet     =   0
         FontPitchAndFamily=   2
         ParagraphAlign  =   3
      End
      Begin MSForms.CommandButton CmdModificar 
         Height          =   375
         Left            =   120
         TabIndex        =   11
         Top             =   720
         Width           =   1335
         Caption         =   " Modificar"
         PicturePosition =   327683
         Size            =   "2355;661"
         Picture         =   "FTipoCambio.frx":0998
         FontHeight      =   165
         FontCharSet     =   0
         FontPitchAndFamily=   2
         ParagraphAlign  =   3
      End
      Begin MSForms.CommandButton CmdNuevo 
         Height          =   375
         Left            =   120
         TabIndex        =   10
         Top             =   240
         Width           =   1335
         Caption         =   " Nuevo"
         PicturePosition =   327683
         Size            =   "2355;661"
         Picture         =   "FTipoCambio.frx":0F32
         FontHeight      =   165
         FontCharSet     =   0
         FontPitchAndFamily=   2
         ParagraphAlign  =   3
      End
      Begin MSForms.CommandButton CmdSalir 
         Height          =   375
         Left            =   120
         TabIndex        =   15
         Top             =   3840
         Width           =   1335
         Caption         =   " Salir"
         PicturePosition =   327683
         Size            =   "2355;661"
         Picture         =   "FTipoCambio.frx":108C
         FontHeight      =   165
         FontCharSet     =   0
         FontPitchAndFamily=   2
         ParagraphAlign  =   3
      End
   End
   Begin VB.Frame FraDatos 
      Enabled         =   0   'False
      Height          =   1095
      Left            =   1800
      TabIndex        =   4
      Top             =   3720
      Width           =   5655
      Begin MSComCtl2.DTPicker dtpFecha 
         Height          =   315
         Left            =   1920
         TabIndex        =   6
         Top             =   240
         Width           =   1335
         _ExtentX        =   2355
         _ExtentY        =   556
         _Version        =   393216
         Format          =   58851329
         CurrentDate     =   39576
      End
      Begin VB.TextBox txtCambio 
         Alignment       =   1  'Right Justify
         Height          =   285
         Left            =   1920
         MaxLength       =   10
         TabIndex        =   8
         Text            =   "0.00"
         Top             =   600
         Width           =   1095
      End
      Begin VB.Label Label1 
         Alignment       =   1  'Right Justify
         Caption         =   "Tipo de cambio:"
         Height          =   255
         Left            =   600
         TabIndex        =   7
         Top             =   600
         Width           =   1215
      End
      Begin VB.Label Label3 
         Alignment       =   1  'Right Justify
         Caption         =   "Nombre:"
         Height          =   255
         Left            =   960
         TabIndex        =   5
         Top             =   240
         Width           =   855
      End
   End
   Begin VB.ComboBox cmbMonedas 
      Height          =   315
      Left            =   2640
      TabIndex        =   2
      Top             =   600
      Width           =   1935
   End
   Begin MSHierarchicalFlexGridLib.MSHFlexGrid HFG 
      Height          =   2535
      Left            =   1800
      TabIndex        =   3
      Top             =   1080
      Width           =   5655
      _ExtentX        =   9975
      _ExtentY        =   4471
      _Version        =   393216
      FixedCols       =   0
      GridColor       =   12632256
      AllowBigSelection=   0   'False
      SelectionMode   =   1
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _NumberOfBands  =   1
      _Band(0).Cols   =   2
   End
   Begin VB.Label labTitulo 
      AutoSize        =   -1  'True
      Caption         =   "TIPO DE CAMBIO"
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   -1  'True
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      Height          =   420
      Left            =   2317
      TabIndex        =   0
      Top             =   0
      Width           =   2940
   End
   Begin VB.Label Label2 
      Alignment       =   1  'Right Justify
      Caption         =   "Moneda:"
      Height          =   255
      Left            =   1800
      TabIndex        =   1
      Top             =   600
      Width           =   735
   End
End
Attribute VB_Name = "FTipoCambio"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private codigo As String
Private fila As Integer

Private Sub cmbMonedas_Click()
    cargarDatos
End Sub

Private Sub CmdNuevo_Click()
    limpiarDatos
    habilitaBotones False
    habilitaFraDatos True
    enfocaControlInicial
    codigo = ""
End Sub
Private Sub CmdModificar_Click()
    fila = HFG.Row
    If fila > 0 Then
        habilitaBotones False
        habilitaFraDatos True
        enfocaControlInicial
        codigo = HFG.TextMatrix(fila, 0)
    End If
End Sub
Private Sub CmdEliminar_Click()
    Dim o As ClsTipoCambio
    fila = HFG.Row
    If fila > 0 Then
        codigo = HFG.TextMatrix(fila, 0)
        If MsgBox(MConfirma_Borrar, vbOKCancel) = vbOK Then
            Set o = New ClsTipoCambio
            o.Borrar codigo
            cargarDatos
        End If
        codigo = ""
        fila = 0
    End If
End Sub

Private Sub cmdGuardar_Click()
    Dim o As ClsTipoCambio
    If codigo = "" Then
        'nuevo registro
        Set o = New ClsTipoCambio
        o.Nuevo Me.cmbMonedas.ItemData(cmbMonedas.ListIndex), CambiaFecha(dtpFecha.value, True), Me.txtCambio.Text
    ElseIf codigo <> "" Then
        'modifica registro
        Set o = New ClsTipoCambio
        o.Modificar codigo, Me.cmbMonedas.ItemData(cmbMonedas.ListIndex), CambiaFecha(dtpFecha.value, True), Me.txtCambio.Text
    End If
    'actualiza datos
    cargarDatos
    'deshabilita botones
    Call cmdCancelar_Click
End Sub
Private Sub cmdCancelar_Click()
    habilitaBotones True
    habilitaFraDatos False
    If fila > 0 Then
        HFG.Row = fila
        'HFG.RowSel = fila
    End If
    HFG.SetFocus
    HFG.Row = 0
End Sub

Private Sub CmdSalir_Click()
    Unload Me
End Sub
Private Sub limpiarDatos()
    dtpFecha.value = FechaHoyServidor
    txtCambio.Text = "0.00"
End Sub
Private Sub habilitaFraDatos(habilitado As Boolean)
    HFG.enabled = Not habilitado
    cmbMonedas.enabled = Not habilitado
    FraDatos.enabled = habilitado
End Sub
Private Sub habilitaBotones(habilitado As Boolean)
    CmdNuevo.Visible = habilitado
    CmdModificar.Visible = habilitado
    CmdEliminar.Visible = habilitado
    CmdSalir.Visible = habilitado
    cmdGuardar.Visible = Not habilitado
    cmdCancelar.Visible = Not habilitado
End Sub
Private Sub enfocaControlInicial()
    With dtpFecha
        .SetFocus
        '.SelStart = 0
        '.SelLength = Strings.LenB(.Text)
    End With
End Sub

Private Sub Form_Load()
    alineaForm Me, 2, 2
    Dim m As ClsMoneda
    Set m = New ClsMoneda
    m.llenaCombo Me.cmbMonedas, False, False
    cmbMonedas.ListIndex = 0
    'cargarDatos
End Sub

Private Sub HFG_EnterCell()
    If HFG.Row > 0 Then
        dtpFecha.value = HFG.TextMatrix(HFG.Row, 2)
        txtCambio.Text = HFG.TextMatrix(HFG.Row, 3)
    End If
End Sub

Public Sub cargarDatos()
    Dim sql As ClsSQL
    Set sql = New ClsSQL
    sql.setCampos Array(tpc_id, tpc_mon_id, formatFechaSQL(tpc_fecha), formatFuncSQL(tpc_cambio, 2))
    sql.setTablas Array(tpc)
    sql.setCondiciones Array(tpc_mon_id & "=" & cmbMonedas.ItemData(cmbMonedas.ListIndex))
    sql.setOrden Array(tpc_fecha & " DESC")
    MUtiles.llenaGrillaSQL HFG, sql.sSelect, Array(0, 0, 90 * 15, 75 * 15), _
                                             Array("Codigo", "Moneda", "Fecha", "T.C."), _
                                             Array(alineaDer, alineaDer, alineaDer, alineaDer)
    limpiarDatos
End Sub

'eventos de movimiento entre controles
Private Sub txtCambio_KeyPress(KeyAscii As Integer)
    KeyAscii = NroDecimal(txtCambio, KeyAscii)
End Sub
